var loginname,loginkey;
$(function(){	
	loginname = $.session.get("username");
	loginkey = $.session.get("user_secretkey");
})
function add_card(){
	var card_num=$("#card_num").val();
	var card_money=$("#card_money").val();
	var card_end_time=$("#card_end_time").val();
	if(card_num==""){
		alert("请输入数量!");
		return false;
	}
	if(card_money==""){
		alert("请输入金额!");
		return false;
	}
	if(card_end_time==""){
		alert("请选择有效期!");
		return false;
	}
	top.layer.confirm('是否确认生成'+card_num+'张,金额为'+card_money+'的实体卡？',{icon: 3,title:'提示信息'},function(index){	
	var index = top.layer.msg('生成中，请稍候',{icon: 16,time:false,shade:0.8});	
		console.log(loginname + "','" + loginkey + "','" + card_num + "','" + card_money + "','" + card_end_time);
		setTimeout(function(){
			$.ajax({
				url: "../../../../service",
				cache: false,
				data: {
					proc: "xmy_zyr.add_card",
					para: "['" + loginname + "','" + loginkey + "','" + card_num + "','" + card_money + "','" + card_end_time + "']"
				},
				dataType: "json",
				success: function(data) {
					console.log(JSON.stringify(data));
					if(data[0].TAG=='1'){
						
						top.layer.alert(""+data[0].MSG+"",function(index){
						   window.location.href="../admin/html/promote/card/experience_card.html";
						   top.layer.closeAll();
						   layer.close(index);	
						});	
						layer.close(index);	
					}else if(data[0].TAG=='0'){
						top.layer.msg(""+data[0].MSG+"");	
					}
				}
			}); 
		},1000);
	});
}
function reback(){
	window.location.href="experience_card.html";
}